"""认证相关Schema定义"""
from marshmallow import Schema, fields, validate
from flask_babel import gettext as _


class LoginSchema(Schema):
    """登录Schema"""
    
    username = fields.String(
        required=True,
        validate=validate.Length(min=1),
        metadata={'description': '用户名或邮箱', 'example': 'john_doe'}
    )
    password = fields.String(
        required=True,
        validate=validate.Length(min=1),
        load_only=True,
        metadata={'description': '密码', 'example': 'password123'}
    )


class TokenSchema(Schema):
    """令牌响应Schema"""
    
    access_token = fields.String(
        required=True,
        metadata={'description': 'JWT访问令牌', 'example': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...'}
    )
    token_type = fields.String(
        required=True,
        metadata={'description': '令牌类型', 'example': 'Bearer'}
    )
    expires_in = fields.Integer(
        required=True,
        metadata={'description': '令牌过期时间（秒）', 'example': 3600}
    )


class RefreshTokenSchema(Schema):
    """刷新令牌Schema"""
    
    refresh_token = fields.String(
        required=True,
        metadata={'description': '刷新令牌', 'example': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...'}
    )


class ChangePasswordSchema(Schema):
    """修改密码Schema"""
    
    old_password = fields.String(
        required=True,
        validate=validate.Length(min=1),
        load_only=True,
        metadata={'description': '原密码', 'example': 'old_password123'}
    )
    new_password = fields.String(
        required=True,
        validate=validate.Length(min=6, max=128),
        load_only=True,
        metadata={'description': '新密码', 'example': 'new_password123'}
    )


class ResetPasswordRequestSchema(Schema):
    """重置密码请求Schema"""
    
    email = fields.Email(
        required=True,
        metadata={'description': '邮箱地址', 'example': 'john@example.com'}
    )


class ResetPasswordSchema(Schema):
    """重置密码Schema"""
    
    token = fields.String(
        required=True,
        metadata={'description': '重置令牌', 'example': 'reset_token_here'}
    )
    new_password = fields.String(
        required=True,
        validate=validate.Length(min=6, max=128),
        load_only=True,
        metadata={'description': '新密码', 'example': 'new_password123'}
    ) 